﻿<UserControl x:Class="Kiva7.Pages.LenderGraphsControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:my="clr-namespace:AmCharts.Windows.QuickCharts;assembly=AmCharts.Windows.QuickCharts.WP"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    d:DesignHeight="480" d:DesignWidth="480">
    
    <ScrollViewer>
        <StackPanel x:Name="LayoutRoot">



            <TextBlock Text="{Binding Path=L.LoansByMonth, Source={StaticResource L}}"  Style="{StaticResource KivaTextNormalStyle}"
                   Canvas.Top="0"/>
            <my:SerialChart x:Name="loansChart" 
                DataSource="{Binding Loans.LoansTotals}" 
                CategoryValueMemberPath="Label"
                AxisForeground="White" 
                LegendVisibility="Collapsed"
                PlotAreaBackground="Black"
                GridStroke="DarkGray"
                Height="240" 
                Width="480"
                Canvas.Top="0">
            <my:SerialChart.Graphs>
                <my:LineGraph ValueMemberPath="Count" Brush="Blue" />
            </my:SerialChart.Graphs>
        </my:SerialChart>

        <!--                <my:LineGraph ValueMemberPath="CountRepaying" Brush="Yellow" />
                <my:LineGraph ValueMemberPath="CountPaid" Brush="Green" />
                <my:LineGraph ValueMemberPath="CountDefaulted" Brush="Red" /> -->

            <TextBlock Text="{Binding Path=L.LoansByStatus, Source={StaticResource L}}"  Style="{StaticResource KivaTextNormalStyle}"
                   Canvas.Top="480" />
            <my:PieChart x:Name="pie1" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2"
                          TitleMemberPath="Title" DataSource="{Binding Loans.LoansPerType}" 
                          ValueMemberPath="CountAsDouble" LegendVisibility="Visible"   
                          Height="240" Width="480" Canvas.Top="240">
            <my:PieChart.Brushes>
                <SolidColorBrush Color="#000099"/>
                <SolidColorBrush Color="#990066"/>
                <SolidColorBrush Color="#660099"/>
                <SolidColorBrush Color="#006600"/>
                <SolidColorBrush Color="#CC9900"/>
                <SolidColorBrush Color="#990000"/>
            </my:PieChart.Brushes>
            <my:PieChart.Template>
                <ControlTemplate TargetType="my:PieChart">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Padding="{TemplateBinding Padding}"
                            >
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>

                            <Border x:Name="PART_SliceCanvasDecorator" Background="Transparent"
                                            Grid.Column="0">
                                <Canvas x:Name="PART_SliceCanvas" />
                            </Border>

                            <my:Legend x:Name="PART_Legend" 
                                               Grid.Column="1"
                                               HorizontalAlignment="Right" VerticalAlignment="Top"
                                        Margin="12,0,0,0" 
                                        Visibility="{TemplateBinding LegendVisibility}"
                                        />
                        </Grid>
                    </Border>
                </ControlTemplate>
            </my:PieChart.Template>
        </my:PieChart>


            <TextBlock Text="{Binding Path=L.LoansByCountry, Source={StaticResource L}}"  Style="{StaticResource KivaTextNormalStyle}"
                   Canvas.Top="720"/>
            <my:PieChart x:Name="loansPerCountry" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2"
                          TitleMemberPath="Key" DataSource="{Binding Loans.LoansPerCountry.Values}" 
                          ValueMemberPath="Value" LegendVisibility="Visible"
                          Height="240" Width="480" Canvas.Top="480">
                <my:PieChart.Template>
                    <ControlTemplate TargetType="my:PieChart">
                        <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Padding="{TemplateBinding Padding}"
                            >
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition />
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>

                                <Border x:Name="PART_SliceCanvasDecorator" Background="Transparent"
                                            Grid.Column="0">
                                    <Canvas x:Name="PART_SliceCanvas" />
                                </Border>

                                <my:Legend x:Name="PART_Legend" 
                                               Grid.Column="1"
                                               HorizontalAlignment="Right" VerticalAlignment="Top"
                                        Margin="12,0,0,0" 
                                        Visibility="{TemplateBinding LegendVisibility}"
                                        />
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </my:PieChart.Template>
            </my:PieChart>



            <TextBlock Text="{Binding Path=L.LoansBySector, Source={StaticResource L}}"  Style="{StaticResource KivaTextNormalStyle}"
                   Canvas.Top="960"/>
            <my:PieChart x:Name="loansPerSector" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2"
                          TitleMemberPath="Key" DataSource="{Binding Loans.LoansPerSector.Values}" 
                          ValueMemberPath="Value" LegendVisibility="Visible"
                          Height="240" Width="480" Canvas.Top="720">
                <my:PieChart.Template>
                    <ControlTemplate TargetType="my:PieChart">
                        <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Padding="{TemplateBinding Padding}"
                            >
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition />
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>

                                <Border x:Name="PART_SliceCanvasDecorator" Background="Transparent"
                                            Grid.Column="0">
                                    <Canvas x:Name="PART_SliceCanvas" />
                                </Border>

                                <my:Legend x:Name="PART_Legend" 
                                               Grid.Column="1"
                                               HorizontalAlignment="Right" VerticalAlignment="Top"
                                        Margin="12,0,0,0" 
                                        Visibility="{TemplateBinding LegendVisibility}"
                                        />
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </my:PieChart.Template>
            </my:PieChart>

        </StackPanel>
    </ScrollViewer>
</UserControl>
